From ccc449fa28768f139b7a568181d02bbce02561f9 Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 3 Aug 2009 05:16:23 +0000 Subject: [PATCH] More roughing in of auto-update. It's not very functional right now; server and client sides are not very attuned to each other... --- gui/babeldata.h | 8 ++++++-- gui/mainwindow.cpp | 4 ++-- gui/upgrade.cpp | 22 ++++++++++++++++------ gui/upgrade.h | 3 ++- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/gui/babeldata.h b/gui/babeldata.h index dae04c227..14db1dce8 100644 --- a/gui/babeldata.h +++ b/gui/babeldata.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: babeldata.h,v 1.2 2009/07/31 18:32:32 robertl Exp $ +// $Id: babeldata.h,v 1.3 2009/08/03 05:16:23 robertl Exp $ //------------------------------------------------------------------------ // // Copyright (C) 2009 S. Khai Mong . @@ -25,6 +25,7 @@ #include #include +#include #include "setting.h" @@ -54,7 +55,8 @@ public: outputBrowse(QString()), previewGmap(false), upgradeCheckMethod(0), - upgradeCheckTime(QDateTime(QDate(2001, 1, 1), QTime(0, 0))) + upgradeCheckTime(QDateTime(QDate(2001, 1, 1), QTime(0, 0))), + installationUuid(QUuid::createUuid().toString()) { }; @@ -96,6 +98,7 @@ public: sg.addVarSetting(new BoolSetting("app.previewGmap", previewGmap)); sg.addVarSetting(new IntSetting("app.upgradeCheckMethod", upgradeCheckMethod)); sg.addVarSetting(new DateTimeSetting("app.upgradeCheckTime", upgradeCheckTime)); + sg.addVarSetting(new StringSetting("app.installationUuid", installationUuid)); } static const int noType; @@ -130,6 +133,7 @@ public: bool previewGmap; int upgradeCheckMethod; QDateTime upgradeCheckTime; + QString installationUuid; }; diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 8913080aa..ac766e59a 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: mainwindow.cpp,v 1.2 2009/07/31 18:32:32 robertl Exp $ +// $Id: mainwindow.cpp,v 1.3 2009/08/03 05:16:23 robertl Exp $ //------------------------------------------------------------------------ // // Copyright (C) 2009 S. Khai Mong . @@ -188,7 +188,7 @@ MainWindow::MainWindow(QWidget* parent): QMainWindow(parent) //--- Restore from registry restoreSettings(); upgrade = new UpgradeCheck(); - upgrade->checkForUpgrade(babelVersion, bd.upgradeCheckMethod, bd.upgradeCheckTime); + upgrade->checkForUpgrade(babelVersion, bd.upgradeCheckMethod, bd.upgradeCheckTime, bd.installationUuid); } //------------------------------------------------------------------------ diff --git a/gui/upgrade.cpp b/gui/upgrade.cpp index 799cfe03d..b8efbdfbb 100644 --- a/gui/upgrade.cpp +++ b/gui/upgrade.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: upgrade.cpp,v 1.2 2009/07/31 18:32:32 robertl Exp $ +// $Id: upgrade.cpp,v 1.3 2009/08/03 05:16:23 robertl Exp $ /* Copyright (C) 2009 Robert Lipe, robertlipe@gpsbabel.org @@ -23,11 +23,12 @@ #include "upgrade.h" #include +//#include #include #include -//static const bool testing = true; -static const bool testing = false; +static const bool testing = true; +// static const bool testing = false; static int versionAsNumber(const QString &s) { @@ -57,7 +58,8 @@ void UpgradeCheck::changeEvent(QEvent *) UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade(const QString ¤tVersion, int checkMethod, - const QDateTime &lastCheckTime) + const QDateTime &lastCheckTime, + const QString &installationUuid) { this->currentVersion = currentVersion; this->upgradeCheckMethod = checkMethod; @@ -74,9 +76,17 @@ UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade(const QString ¤tV connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)), this, SLOT(readResponseHeader(const QHttpResponseHeader &))); + QHttpRequestHeader header("POST", "/upgrade_check.html"); + header.setValue("Host", "www.gpsbabel.org"); + header.setContentType("application/x-www-form-urlencoded"); + QString args = "current_version=" + currentVersion; + args += "&installation=" + installationUuid; header.setValue("Host", "www.gpsbabel.org"); + http->setHost("www.gpsbabel.org"); - httpRequestId = http->get("/updates.xml"); - +// http->request(header); + http->request(header, args.toUtf8()); +// httpRequestId = http->get("/upgrade_check.html"); + return UpgradeCheck::updateUnknown; } diff --git a/gui/upgrade.h b/gui/upgrade.h index 6b7681b1e..914e305a7 100644 --- a/gui/upgrade.h +++ b/gui/upgrade.h @@ -41,7 +41,8 @@ public: UpgradeCheck::updateStatus checkForUpgrade(const QString &babelVersion, int upgradeCheckMethod, - const QDateTime &lastCheckTime); + const QDateTime &lastCheckTime, + const QString &installationUuid); QDateTime getUpgradeWarningTime() { return upgradeWarningTime; } -- 2.30.2